<template>
    <a-spin :spinning="loading">
      <a-card :bordered="false">
        <title-name title="重要节点"></title-name>
        <list-table
          ref="table"
          size="default"
          :row-key="record=>record.id"
          :columns="columns"
          :request="loadData"
          :alert="true"
          :isFixedRight="false"
          show-pagination="auto"
        >
            <span
                slot="serial"
                slot-scope="text, record, index"
            >{{ index + 1 }}</span>
        </list-table>
      </a-card>
    </a-spin>
  </template>
  
  <script>
  import { queryKeyNodesQueryDetailDetail } from '@/api/project/plannManagement/importantNodes.js'
  
    const columns = [
      {
        title: '序号',
        scopedSlots: { customRender: 'serial' }
      },
      {
        title: '阶段/类别',
        dataIndex: 'phaseCategory'
      },
      {
        title: '重要节点内容',
        dataIndex: 'businessMatters'
      },
      {
        title: '计划开始时间',
        dataIndex: 'startDate',
      },
      {
        title: '计划结束时间',
        dataIndex: 'endDate',
      },
      {
        title: '备注',
        dataIndex: 'controlLevelName',
        // scopedSlots: { customRender: 'action' }
      }
    ]
  
    export default {
      name:'a'+Date.now(),
      data() {
        this.columns = columns
        return {
          total: 0,
          // 查询参数
          queryParam: {
            param: {
                "latestData": true,
                "schemeDetailId": this.$route.query.id,
                "version": this.$route.query.version || 0,
            }
            
          },
          loading: false,
          // 加载数据方法 必须为 Promise 对象
          loadData: parameter => {
            const requestParameters = Object.assign({}, parameter, this.queryParam)
            requestParameters.pageNum = requestParameters.pageNo
            return queryKeyNodesQueryDetailDetail(requestParameters)
              .then(res => {
                this.total = res.totalSize;
                return res
              })
          },
        }
      },
      methods: {
        importantNodesSaveDrafts(baseData) {
          this.submitFn(0, baseData)
        },
        importantNodesSubmit(baseData) {
          this.$confirm({
            title: '温馨提示',
            content: '请确认是否要提交?',
            onOk: () => {
              this.submitFn(1, baseData)
            },
            onCancel: () => { this.$emit('update:spinning', false)}
          })
          
        },
        submitFn(status, baseData) {
            this.$emit('update:spinning', true)
            baseData.schemeDetailId = this.$route.query.id
            baseData.status = status
            this.$emit('updateBasicDetail', baseData)
            this.$message.success('保存成功')
            this.$emit('closePage');
        },
      }
    }
  </script>
  
  
  